<template>
	<div>
		<!--配送方式  将高度设置为0 暂不展示-->         
        <ul class="aui-list aui-form-list aui-margin-b-15" v-if="false">
            <li class="aui-list-item" style="text-align: left;">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">配送方式<font class="required">*</font></div>
                    <div class="aui-list-item-input nav" >
                    	<div style="white-space: nowrap;height: 2.6rem;line-height: 2.6rem;">
                    		<label v-for="(item, index) in arrLogistics" :key="index" style="padding-left: 0.2rem;">
	                          	<input class="aui-radio" type="radio" id="myRadio" name="demo1" :checked="(index+1) == activeIndex" @click="changeMethod($event,index,item)">
	                       		<span style="margin-left: 3px;">{{item.name}}</span>
	                        </label> &nbsp;&nbsp;
                    	</div>
                    </div>
                </div>
            </li>
        </ul>
        <!--配送方式end-->
	</div>
</template>

<script>
	import {mapGetters,mapMutations} from 'vuex';
	import axios from "axios";
	export default {
		props: {
           methodList:{
           		type:Array,
           		default:function(){
           			let arr = [];
           			return arr
           		}
           },
           flag:{
	           	type:Boolean,
	           	default:function(){
	           		return true
	           	}
           }
        },
        computed:{
        	...mapGetters([
        		"getConfigParams"
        	])
        },
        watch:{
        	
        },
        data () {
            return {
               cartList:[],
               num:null,
               money:null,
               arrLogistics:[], // 物流方式  活的数据 暂未渲染
               myArr:[{
               		name:'快递物流',
               		value:"KDWL"
               },
               {
               		name:'到店自提',
               		value:"DDZT"
               },
               {
               		name:'同城配送',
               		value:"TCPS"
               },{
               		name:'无需物流',
               		value:"WXWL"
               }
               ],  // 死的数据  暂时渲染
               activeIndex:1
            }
        },
        methods: {
        	...mapMutations('zx',[
        		"setDeliveryType","setStoreNow"
        	]),
        	getLogistics(){
        		this.getMethods();
        	},
        	getMethods(){
        		var url = window.api.base_host + "/baseStore/getStoreInfo";
        		var params = {
        			storeCode:localStorage.getItem("storeCode"),
        			storeFlag:true
        		}
        		var config = {
        			url: url,
					method: "GET",
					params,
					headers: {
						'sessionId': window.localStorage.getItem("sessionId")
					}
        		}
        		
        		axios(config).then((res)=>{
//      			console.log(res.data.data[0][0],'门店对象');
        			let arr = res.data.data[0][0].servicesTypeCode.split(' ')
        			// console.log(arr);
//      			let arr = this.getConfigParams.logisticsServeList.split(',');
        		
	        		for(let i = 0; i < arr.length;i++){
	        			let obj = {};
	        			obj.value = arr[i];
	        			if(arr[i] === 'KDWL'){
	        				obj.name = '快递物流';
	        				obj.value = "KDWL";
	        				this.arrLogistics.push(obj);	
	        			}else if(arr[i] === 'DDZT'){
	        				obj.name = '到店自提';
	        				obj.value = "DDZT";
	        				this.arrLogistics.push(obj);
	        			}else if(arr[i] === 'TCPS'){
	        				obj.name = '同城配送';
	        				obj.value = "TCPS";
	        				this.arrLogistics.push(obj);
	        			}else if(arr[i] === 'WXWL'){
	        				obj.name = '无需物流';
	        				obj.value = "WXWL";
	        				this.arrLogistics.push(obj);
	        			}
	        		}
	        		this.setStoreNow(res.data.data[0][0]);  //存当前门店信息
	        		this.setDeliveryType(this.arrLogistics[0].value);
        		})
        	},
        	changeMethod(mevent,index,item){
        		this.activeIndex = index+1;
				// console.log(item.value,item);
				this.setDeliveryType(item.value);
        	}
        },
        created(){
        	this.getLogistics();
        	
        },
        beforeDestroy(){
        	this.setDeliveryType(null);
        }
	}
</script>

<style scoped="scoped">
	.nav {
	    width: 100%;
	    height: 2.6rem;
	    background: white;
	    overflow-x: auto;
	    overflow-y: hidden;
	    line-height: 2.2rem;
	}
	#myRadio{
		vertical-align: middle;
	}
</style>